﻿using System;
using System.Collections.Generic;

namespace ITM495.OOExamples.Core
{
    /// <summary>
    /// Options is a helper class that parses
    /// a command line array and creates a dictionary of name value pairs
    /// out of all the parameters
    /// </summary>
    public class Options: Dictionary<string, string>
    {
        public String ControllerName { get; protected set; }

        /// <summary>
        /// Creates a new instance of the Options class by parsing an array of command line arguments
        /// </summary>
        /// <param name="commandLine"></param>
        public Options(String[] commandLine)
        {
            if (commandLine == null || commandLine.Length == 0)
            {
                ControllerName = "help";
                return;
            }

            ControllerName = commandLine[0];

            for(int i = 1; i< commandLine.Length; i = i + 2)
            {
                Add(commandLine[i], commandLine[i +1]);
            }
        }
    }
}